﻿namespace TestTool.GUI.Utils
{
    using System;
    using System.Collections.Generic;
    using System.Runtime.CompilerServices;
    using System.Text;
    using TestTool.Tests.Definitions.Data;
    using TestTool.Tests.Definitions.Enums;

    internal static class Converter
    {
        private static string GetFeaturesString(this IList<Feature> features)
        {
            if (features.Count > 0)
            {
                StringBuilder builder = new StringBuilder(FeaturesHelper.GetDisplayName(features[0]));
                for (int i = 1; i < features.Count; i++)
                {
                    builder.AppendFormat(", {0}", FeaturesHelper.GetDisplayName(features[i]));
                }
                return builder.ToString();
            }
            return "UNDEFINED";
        }

        public static string GetRequirementString(this TestInfo testInfo)
        {
            string str = string.Empty;
            if (testInfo.RequiredFeatures.Count == 0)
            {
                if (testInfo.RequirementLevel == RequirementLevel.Must)
                {
                    return "RUN ALWAYS";
                }
                return "RUN IN DIAGNOSTIC ONLY";
            }
            string featuresString = testInfo.RequiredFeatures.GetFeaturesString();
            string str3 = (testInfo.RequirementLevel == RequirementLevel.Must) ? "RUN" : "RUN IN DIAGNOSTIC ONLY";
            return (str + string.Format("{0} IF SUPPORTED ({1})", str3, featuresString));
        }
    }
}

